// 设置Token
export const setToken = (token) => {
	uni.setStorageSync('token', token);
}
// 获取Token
export const getToken = () => {
	return uni.getStorageSync('token') || ''
}
// 删除Token
export const removeToken = () => {
	uni.removeStorageSync('token');
}
// 加密手机号
export const gardMobile = (phoneNumber) => {
  return phoneNumber.replace(/^(\d{3})\d{4}(\d{4})$/, "$1****$2");
}
// 手机号校验规则
export const checkMobile = (phoneNumber) => {
	const phoneReg = /^1[34578]\d{9}/;
  return phoneReg.test(phoneNumber)
}
// 身份证校验规则
export const isValidID = (id) => {
    var pattern = /^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/;
    return pattern.test(id);
}
// 银行卡校验规则
export const isValidBankCardNumber = (bankCardNumber) => {
    const pattern = /^\d{16,19}$/;
    return pattern.test(bankCardNumber);
}
// 加密银行卡
export const hideBankCardNumber = (cardNumber) => {
  const hiddenNumbers = cardNumber.slice(0, -4).replace(/[0-9]/g, '*');
  const lastFourDigits = cardNumber.slice(-4);
  // const maskedCardNumber = hiddenNumbers + lastFourDigits;
	const maskedCardNumber = '****' + lastFourDigits;
  return maskedCardNumber;
}
